package com.cjy.expenses.extra;

import com.cjy.payment.alipay.entity.AlipayNotifyEntity;
import com.cjy.payment.privatebusiness.PrivateBusiness;
import com.cjy.payment.unionpay.acp.entity.UnionpayNotifyEntity;
import com.cjy.payment.weixin.bean.WeixinNotifyEntity;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service("doNotify")
public class DoNotify extends ApplicationObjectSupport implements PrivateBusiness{
	
	private DoFee doFee = new DoFee();
	
	
	@Transactional
	@Override
	public void excuteAlipayPrivateBusiness(
			final AlipayNotifyEntity alipayNotifyEntity) {
		try {
			Runnable runnable = new Runnable() {
				
				@Override
				public void run() {
					
					doFee.doFeeI(alipayNotifyEntity);
				}
			};
			
			Thread thread = new Thread(runnable);
			thread.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

	@Override
	public void excuteWeixinPrivateBusiness(
			final WeixinNotifyEntity weixinNotifyEntity) {
		try {
			Runnable runnable = new Runnable() {
				
				@Override
				public void run() {
					doFee.doFeeW(weixinNotifyEntity);
				}
			};
			
			Thread thread = new Thread(runnable);
			thread.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void excuteUnionpayPrivateBusiness(
			final UnionpayNotifyEntity unionpayNotifyEntity) {
		try {
			Runnable runnable = new Runnable() {
				
				@Override
				public void run() {
					
					doFee.doFeeU(unionpayNotifyEntity);
				}
			};
			
			Thread thread = new Thread(runnable);
			thread.start();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
